// 等效window.onload事件

$(function(){
    $("#loginBtn").click(function(){
        let userName=$("#userName").val();//获取用户名
        let password=$("#password").val();//获取密码
        $.ajax({
            url:'/login',
            type:'post',
            data:{
                userName:userName,
                password:password
            },
            dataType:'json',
            success:function(result){
                if(result.errorMsg){
                    layer.msg(result.errorMsg,{icon:5});
                }else{
                    window.location.href='/';
                }
            }
        });
    });
})